<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="list">
        <li>01</li>
        <li>02</li>
        <li>03</li>
        <li>04</li>
        <li>05</li>
        <li>06</li>
        <li>07</li>
        <li>08</li>
        <li>09</li>
        <li>10</li>
    </div>
</body>
<script>
    // 1.伪数组转真数组  call应用
    var liList = document.querySelectorAll(".list li");
    Array.prototype.mySlice = function (startIndex = 0, endIndex = this.length) {
        var arr = [];
        for (var i = startIndex; i < endIndex; i++) {
            var item = this[i];
            arr.push(item);
        }
        return arr;
    }
    // liList.mySlice();  报错
    var list = Array.prototype.mySlice.call(liList, 1, 4);
    console.log(list);


    // 2.找最小数 apply应用
    var list = [2, 8, 4, 6, 7, 9, 3, 1];

    var min = Math.min(...list);   //新版本直接找

    var min = Math.min.apply(null, list);  // 老版本
    console.log(min);


    // 3.判断一个数据是否是纯对象
    var arr = new Array(1, 2, 3, 4);
    var obj = { a: 1, b: 2 };
    var date = new Date();
    var p = new Promise(function () { });
    var err = new Error(333);
    function Fn(a, b) {
        this.a = a;
        this.b = b;
    }
    var data = new Fn(3, 4);

    // 全都是"ovject" => 如何判断一个数据是否是纯对象 {}
    console.log(arr, typeof arr);
    console.log(obj, typeof obj);
    console.log(date, typeof date);
    console.log(p, typeof p);
    console.log(err, typeof err);
    console.log(data, typeof data);


    console.log(Object.prototype.toString.call(arr))  // [object Array]
    console.log(Object.prototype.toString.call(obj)) // [object Object]
    console.log(Object.prototype.toString.call(date)) // [object Date]
    console.log(Object.prototype.toString.call(p)) // [object Promise]
    console.log(Object.prototype.toString.call(err)) // [object Error]
    console.log(Object.prototype.toString.call(data)) // [object Object]

</script>

</html>